<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: LinkedList</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">mimic</a> ]
    </div>

    <h1>Coverage Summary for Class: LinkedList (mimic)</h1>

    <table class="coverageStats">

        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">LinkedList</td>
            <td class="coverageStat">
  <span class="percent">
    8.6%
  </span>
                <span class="absValue">
    (5/ 58)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    14.7%
  </span>
                <span class="absValue">
    (39/ 266)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">LinkedList$DescendingIterator</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 5)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 5)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">LinkedList$ListItr</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 12)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 52)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">LinkedList$LLSpliterator</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 7)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 51)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">LinkedList$Node</td>
            <td class="coverageStat">
  <span class="percent">
    100%
  </span>
                <span class="absValue">
    (1/ 1)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    100%
  </span>
                <span class="absValue">
    (5/ 5)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name"><strong>total</strong></td>
            <td class="coverageStat">
  <span class="percent">
    7.2%
  </span>
                <span class="absValue">
    (6/ 83)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    11.6%
  </span>
                <span class="absValue">
    (44/ 379)
  </span>
            </td>
        </tr>
    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package mimic;
        <i>2</i>&nbsp;/*
        <i>3</i>&nbsp; * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
        <i>4</i>&nbsp; * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        <i>5</i>&nbsp; *
        <i>6</i>&nbsp; * This code is free software; you can redistribute it and/or modify it
        <i>7</i>&nbsp; * under the terms of the GNU General Public License version 2 only, as
        <i>8</i>&nbsp; * published by the Free Software Foundation. Oracle designates this
        <i>9</i>&nbsp; * particular file as subject to the &quot;Classpath&quot; exception as provided
        <i>10</i>&nbsp; * by Oracle in the LICENSE file that accompanied this code.
        <i>11</i>&nbsp; *
        <i>12</i>&nbsp; * This code is distributed in the hope that it will be useful, but WITHOUT
        <i>13</i>&nbsp; * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
        <i>14</i>&nbsp; * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
        <i>15</i>&nbsp; * version 2 for more details (a copy is included in the LICENSE file that
        <i>16</i>&nbsp; * accompanied this code).
        <i>17</i>&nbsp; *
        <i>18</i>&nbsp; * You should have received a copy of the GNU General Public License version
        <i>19</i>&nbsp; * 2 along with this work; if not, write to the Free Software Foundation,
        <i>20</i>&nbsp; * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
        <i>21</i>&nbsp; *
        <i>22</i>&nbsp; * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
        <i>23</i>&nbsp; * or visit www.oracle.com if you need additional information or have any
        <i>24</i>&nbsp; * questions.
        <i>25</i>&nbsp; */
        <i>26</i>&nbsp;
        <i>27</i>&nbsp;import java.util.*;
        <i>28</i>&nbsp;import java.util.function.Consumer;
        <i>29</i>&nbsp;
        <i>30</i>&nbsp;/**
        <i>31</i>&nbsp; * Doubly-linked list implementation of the {@code List} and {@code Deque}
        <i>32</i>&nbsp; * interfaces. Implements all optional list operations, and permits all
        <i>33</i>&nbsp; * elements (including {@code null}).
        <i>34</i>&nbsp; *
        <i>35</i>&nbsp; * &lt;p&gt;All of the operations perform as could be expected for a doubly-linked
        <i>36</i>&nbsp; * list. Operations that index into the list will traverse the list from
        <i>37</i>&nbsp; * the beginning or the end, whichever is closer to the specified index.
        <i>38</i>&nbsp; *
        <i>39</i>&nbsp; * &lt;p&gt;&lt;strong&gt;Note that this implementation is not synchronized.&lt;/strong&gt;
        <i>40</i>&nbsp; * If multiple threads access a linked list concurrently, and at least
        <i>41</i>&nbsp; * one of the threads modifies the list structurally, it &lt;i&gt;must&lt;/i&gt; be
        <i>42</i>&nbsp; * synchronized externally. (A structural modification is any operation
        <i>43</i>&nbsp; * that adds or deletes one or more elements; merely setting the value of
        <i>44</i>&nbsp; * an element is not a structural modification.) This is typically
        <i>45</i>&nbsp; * accomplished by synchronizing on some object that naturally
        <i>46</i>&nbsp; * encapsulates the list.
        <i>47</i>&nbsp; * &lt;p&gt;
        <i>48</i>&nbsp; * If no such object exists, the list should be &quot;wrapped&quot; using the
        <i>49</i>&nbsp; * &lt;p&gt;
        <i>50</i>&nbsp; * method. This is best done at creation time, to prevent accidental
        <i>51</i>&nbsp; * unsynchronized access to the list:&lt;pre&gt;
        <i>52</i>&nbsp; * List list = Collections.synchronizedList(new demo.mimic.LinkedList(...));&lt;/pre&gt;
        <i>53</i>&nbsp; *
        <i>54</i>&nbsp; * &lt;p&gt;The iterators returned by this class&#39;s {@code iterator} and
        <i>55</i>&nbsp; * {@code listIterator} methods are &lt;i&gt;fail-fast&lt;/i&gt;: if the list is
        <i>56</i>&nbsp; * structurally modified at any time after the iterator is created, in
        <i>57</i>&nbsp; * any way except through the Iterator&#39;s own {@code remove} or
        <i>58</i>&nbsp; * {@code add} methods, the iterator will throw a {@link
        <i>59</i>&nbsp; * ConcurrentModificationException}. Thus, in the face of concurrent
        <i>60</i>&nbsp; * modification, the iterator fails quickly and cleanly, rather than
        <i>61</i>&nbsp; * risking arbitrary, non-deterministic behavior at an undetermined
        <i>62</i>&nbsp; * time in the future.
        <i>63</i>&nbsp; *
        <i>64</i>&nbsp; * &lt;p&gt;Note that the fail-fast behavior of an iterator cannot be guaranteed
        <i>65</i>&nbsp; * as it is, generally speaking, impossible to make any hard guarantees in the
        <i>66</i>&nbsp; * presence of unsynchronized concurrent modification. Fail-fast iterators
        <i>67</i>&nbsp; * throw {@code ConcurrentModificationException} on a best-effort basis.
        <i>68</i>&nbsp; * Therefore, it would be wrong to write a program that depended on this
        <i>69</i>&nbsp; * exception for its correctness: &lt;i&gt;the fail-fast behavior of iterators
        <i>70</i>&nbsp; * should be used only to detect bugs.&lt;/i&gt;
        <i>71</i>&nbsp; *
        <i>72</i>&nbsp; * &lt;p&gt;This class is a member of the
        <i>73</i>&nbsp; * &lt;a href=&quot;{@docRoot}/../technotes/guides/collections/index.html&quot;&gt;
        <i>74</i>&nbsp; * Java Collections Framework&lt;/a&gt;.
        <i>75</i>&nbsp; *
        <i>76</i>&nbsp; * @param &lt;E&gt; the type of elements held in this collection
        <i>77</i>&nbsp; * @author Josh Bloch
        <i>78</i>&nbsp; * @see List
        <i>79</i>&nbsp; * @see ArrayList
        <i>80</i>&nbsp; * @since 1.2
        <i>81</i>&nbsp; */
        <i>82</i>&nbsp;
        <b class="nc"><i>83</i>&nbsp;public class LinkedList&lt;E&gt;</b>
        <i>84</i>&nbsp; extends AbstractSequentialList&lt;E&gt;
        <i>85</i>&nbsp; implements List&lt;E&gt;, Deque&lt;E&gt;, Cloneable, java.io.Serializable {
        <i>86</i>&nbsp;
        <i>87</i>&nbsp; private static final long serialVersionUID = 876323262645176354L;
        <i>88</i>&nbsp;
        <b class="fc"><i>89</i>&nbsp; transient int size = 0;</b>
        <i>90</i>&nbsp; /**
        <i>91</i>&nbsp; * Pointer to first node.
        <i>92</i>&nbsp; * Invariant: (first == null &amp;&amp; last == null) ||
        <i>93</i>&nbsp; * (first.prev == null &amp;&amp; first.item != null)
        <i>94</i>&nbsp; */
        <i>95</i>&nbsp; transient Node&lt;E&gt; first;
        <i>96</i>&nbsp; /**
        <i>97</i>&nbsp; * Pointer to last node.
        <i>98</i>&nbsp; * Invariant: (first == null &amp;&amp; last == null) ||
        <i>99</i>&nbsp; * (last.next == null &amp;&amp; last.item != null)
        <i>100</i>&nbsp; */
        <i>101</i>&nbsp; transient Node&lt;E&gt; last;
        <i>102</i>&nbsp;
        <i>103</i>&nbsp; /**
        <i>104</i>&nbsp; * Constructs an empty list.
        <i>105</i>&nbsp; */
        <b class="fc"><i>106</i>&nbsp; public LinkedList() {</b>
        <b class="fc"><i>107</i>&nbsp; }</b>
        <i>108</i>&nbsp;
        <i>109</i>&nbsp; /**
        <i>110</i>&nbsp; * Constructs a list containing the elements of the specified
        <i>111</i>&nbsp; * collection, in the order they are returned by the collection&#39;s
        <i>112</i>&nbsp; * iterator.
        <i>113</i>&nbsp; *
        <i>114</i>&nbsp; * @param c the collection whose elements are to be placed into this list
        <i>115</i>&nbsp; * @throws NullPointerException if the specified collection is null
        <i>116</i>&nbsp; */
        <i>117</i>&nbsp; public LinkedList(Collection&lt;? extends E&gt; c) {
        <b class="nc"><i>118</i>&nbsp; this();</b>
        <b class="nc"><i>119</i>&nbsp; addAll(c);</b>
        <b class="nc"><i>120</i>&nbsp; }</b>
        <i>121</i>&nbsp;
        <i>122</i>&nbsp; /**
        <i>123</i>&nbsp; * Links e as first element.
        <i>124</i>&nbsp; */
        <i>125</i>&nbsp; private void linkFirst(E e) {
        <b class="nc"><i>126</i>&nbsp; final Node&lt;E&gt; f = first;</b>
        <b class="nc"><i>127</i>&nbsp; final Node&lt;E&gt; newNode = new Node&lt;&gt;(null, e, f);</b>
        <b class="nc"><i>128</i>&nbsp; first = newNode;</b>
        <b class="nc"><i>129</i>&nbsp; if (f == null) {</b>
        <b class="nc"><i>130</i>&nbsp; last = newNode;</b>
        <i>131</i>&nbsp; } else {
        <b class="nc"><i>132</i>&nbsp; f.prev = newNode;</b>
        <i>133</i>&nbsp; }
        <b class="nc"><i>134</i>&nbsp; size++;</b>
        <b class="nc"><i>135</i>&nbsp; modCount++;</b>
        <b class="nc"><i>136</i>&nbsp; }</b>
        <i>137</i>&nbsp;
        <i>138</i>&nbsp; /**
        <i>139</i>&nbsp; * Links e as last element.
        <i>140</i>&nbsp; */
        <i>141</i>&nbsp; void linkLast(E e) {
        <b class="fc"><i>142</i>&nbsp; final Node&lt;E&gt; l = last;</b>
        <b class="fc"><i>143</i>&nbsp; final Node&lt;E&gt; newNode = new Node&lt;&gt;(l, e, null);</b>
        <b class="fc"><i>144</i>&nbsp; last = newNode;</b>
        <b class="fc"><i>145</i>&nbsp; if (l == null) {</b>
        <b class="fc"><i>146</i>&nbsp; first = newNode;</b>
        <i>147</i>&nbsp; } else {
        <b class="fc"><i>148</i>&nbsp; l.next = newNode;</b>
        <i>149</i>&nbsp; }
        <b class="fc"><i>150</i>&nbsp; size++;</b>
        <b class="fc"><i>151</i>&nbsp; modCount++;</b>
        <b class="fc"><i>152</i>&nbsp; }</b>
        <i>153</i>&nbsp;
        <i>154</i>&nbsp; /**
        <i>155</i>&nbsp; * Inserts element e before non-null Node succ.
        <i>156</i>&nbsp; */
        <i>157</i>&nbsp; void linkBefore(E e, Node&lt;E&gt; succ) {
        <i>158</i>&nbsp; // assert succ != null;
        <b class="nc"><i>159</i>&nbsp; final Node&lt;E&gt; pred = succ.prev;</b>
        <b class="nc"><i>160</i>&nbsp; final Node&lt;E&gt; newNode = new Node&lt;&gt;(pred, e, succ);</b>
        <b class="nc"><i>161</i>&nbsp; succ.prev = newNode;</b>
        <b class="nc"><i>162</i>&nbsp; if (pred == null) {</b>
        <b class="nc"><i>163</i>&nbsp; first = newNode;</b>
        <i>164</i>&nbsp; } else {
        <b class="nc"><i>165</i>&nbsp; pred.next = newNode;</b>
        <i>166</i>&nbsp; }
        <b class="nc"><i>167</i>&nbsp; size++;</b>
        <b class="nc"><i>168</i>&nbsp; modCount++;</b>
        <b class="nc"><i>169</i>&nbsp; }</b>
        <i>170</i>&nbsp;
        <i>171</i>&nbsp; /**
        <i>172</i>&nbsp; * Unlinks non-null first node f.
        <i>173</i>&nbsp; */
        <i>174</i>&nbsp; private E unlinkFirst(Node&lt;E&gt; f) {
        <i>175</i>&nbsp; // assert f == first &amp;&amp; f != null;
        <b class="nc"><i>176</i>&nbsp; final E element = f.item;</b>
        <b class="nc"><i>177</i>&nbsp; final Node&lt;E&gt; next = f.next;</b>
        <b class="nc"><i>178</i>&nbsp; f.item = null;</b>
        <b class="nc"><i>179</i>&nbsp; f.next = null; // help GC</b>
        <b class="nc"><i>180</i>&nbsp; first = next;</b>
        <b class="nc"><i>181</i>&nbsp; if (next == null) {</b>
        <b class="nc"><i>182</i>&nbsp; last = null;</b>
        <i>183</i>&nbsp; } else {
        <b class="nc"><i>184</i>&nbsp; next.prev = null;</b>
        <i>185</i>&nbsp; }
        <b class="nc"><i>186</i>&nbsp; size--;</b>
        <b class="nc"><i>187</i>&nbsp; modCount++;</b>
        <b class="nc"><i>188</i>&nbsp; return element;</b>
        <i>189</i>&nbsp; }
        <i>190</i>&nbsp;
        <i>191</i>&nbsp; /**
        <i>192</i>&nbsp; * Unlinks non-null last node l.
        <i>193</i>&nbsp; */
        <i>194</i>&nbsp; private E unlinkLast(Node&lt;E&gt; l) {
        <i>195</i>&nbsp; // assert l == last &amp;&amp; l != null;
        <b class="nc"><i>196</i>&nbsp; final E element = l.item;</b>
        <b class="nc"><i>197</i>&nbsp; final Node&lt;E&gt; prev = l.prev;</b>
        <b class="nc"><i>198</i>&nbsp; l.item = null;</b>
        <b class="nc"><i>199</i>&nbsp; l.prev = null; // help GC</b>
        <b class="nc"><i>200</i>&nbsp; last = prev;</b>
        <b class="nc"><i>201</i>&nbsp; if (prev == null) {</b>
        <b class="nc"><i>202</i>&nbsp; first = null;</b>
        <i>203</i>&nbsp; } else {
        <b class="nc"><i>204</i>&nbsp; prev.next = null;</b>
        <i>205</i>&nbsp; }
        <b class="nc"><i>206</i>&nbsp; size--;</b>
        <b class="nc"><i>207</i>&nbsp; modCount++;</b>
        <b class="nc"><i>208</i>&nbsp; return element;</b>
        <i>209</i>&nbsp; }
        <i>210</i>&nbsp;
        <i>211</i>&nbsp; /**
        <i>212</i>&nbsp; * Unlinks non-null node x.
        <i>213</i>&nbsp; */
        <i>214</i>&nbsp; E unlink(Node&lt;E&gt; x) {
        <i>215</i>&nbsp; // assert x != null;
        <b class="fc"><i>216</i>&nbsp; final E element = x.item;</b>
        <b class="fc"><i>217</i>&nbsp; final Node&lt;E&gt; next = x.next;</b>
        <b class="fc"><i>218</i>&nbsp; final Node&lt;E&gt; prev = x.prev;</b>
        <i>219</i>&nbsp;
        <b class="fc"><i>220</i>&nbsp; if (prev == null) {</b>
        <b class="fc"><i>221</i>&nbsp; first = next;</b>
        <i>222</i>&nbsp; } else {
        <b class="fc"><i>223</i>&nbsp; prev.next = next;</b>
        <b class="fc"><i>224</i>&nbsp; x.prev = null;</b>
        <i>225</i>&nbsp; }
        <i>226</i>&nbsp;
        <b class="fc"><i>227</i>&nbsp; if (next == null) {</b>
        <b class="fc"><i>228</i>&nbsp; last = prev;</b>
        <i>229</i>&nbsp; } else {
        <b class="fc"><i>230</i>&nbsp; next.prev = prev;</b>
        <b class="fc"><i>231</i>&nbsp; x.next = null;</b>
        <i>232</i>&nbsp; }
        <i>233</i>&nbsp;
        <b class="fc"><i>234</i>&nbsp; x.item = null;</b>
        <b class="fc"><i>235</i>&nbsp; size--;</b>
        <b class="fc"><i>236</i>&nbsp; modCount++;</b>
        <b class="fc"><i>237</i>&nbsp; return element;</b>
        <i>238</i>&nbsp; }
        <i>239</i>&nbsp;
        <i>240</i>&nbsp; /**
        <i>241</i>&nbsp; * Returns the first element in this list.
        <i>242</i>&nbsp; *
        <i>243</i>&nbsp; * @return the first element in this list
        <i>244</i>&nbsp; * @throws NoSuchElementException if this list is empty
        <i>245</i>&nbsp; */
        <i>246</i>&nbsp; @Override
        <i>247</i>&nbsp; public E getFirst() {
        <b class="nc"><i>248</i>&nbsp; final Node&lt;E&gt; f = first;</b>
        <b class="nc"><i>249</i>&nbsp; if (f == null) {</b>
        <b class="nc"><i>250</i>&nbsp; throw new NoSuchElementException();</b>
        <i>251</i>&nbsp; }
        <b class="nc"><i>252</i>&nbsp; return f.item;</b>
        <i>253</i>&nbsp; }
        <i>254</i>&nbsp;
        <i>255</i>&nbsp; /**
        <i>256</i>&nbsp; * Returns the last element in this list.
        <i>257</i>&nbsp; *
        <i>258</i>&nbsp; * @return the last element in this list
        <i>259</i>&nbsp; * @throws NoSuchElementException if this list is empty
        <i>260</i>&nbsp; */
        <i>261</i>&nbsp; @Override
        <i>262</i>&nbsp; public E getLast() {
        <b class="nc"><i>263</i>&nbsp; final Node&lt;E&gt; l = last;</b>
        <b class="nc"><i>264</i>&nbsp; if (l == null) {</b>
        <b class="nc"><i>265</i>&nbsp; throw new NoSuchElementException();</b>
        <i>266</i>&nbsp; }
        <b class="nc"><i>267</i>&nbsp; return l.item;</b>
        <i>268</i>&nbsp; }
        <i>269</i>&nbsp;
        <i>270</i>&nbsp; /**
        <i>271</i>&nbsp; * Removes and returns the first element from this list.
        <i>272</i>&nbsp; *
        <i>273</i>&nbsp; * @return the first element from this list
        <i>274</i>&nbsp; * @throws NoSuchElementException if this list is empty
        <i>275</i>&nbsp; */
        <i>276</i>&nbsp; @Override
        <i>277</i>&nbsp; public E removeFirst() {
        <b class="nc"><i>278</i>&nbsp; final Node&lt;E&gt; f = first;</b>
        <b class="nc"><i>279</i>&nbsp; if (f == null) {</b>
        <b class="nc"><i>280</i>&nbsp; throw new NoSuchElementException();</b>
        <i>281</i>&nbsp; }
        <b class="nc"><i>282</i>&nbsp; return unlinkFirst(f);</b>
        <i>283</i>&nbsp; }
        <i>284</i>&nbsp;
        <i>285</i>&nbsp; /**
        <i>286</i>&nbsp; * Removes and returns the last element from this list.
        <i>287</i>&nbsp; *
        <i>288</i>&nbsp; * @return the last element from this list
        <i>289</i>&nbsp; * @throws NoSuchElementException if this list is empty
        <i>290</i>&nbsp; */
        <i>291</i>&nbsp; @Override
        <i>292</i>&nbsp; public E removeLast() {
        <b class="nc"><i>293</i>&nbsp; final Node&lt;E&gt; l = last;</b>
        <b class="nc"><i>294</i>&nbsp; if (l == null) {</b>
        <b class="nc"><i>295</i>&nbsp; throw new NoSuchElementException();</b>
        <i>296</i>&nbsp; }
        <b class="nc"><i>297</i>&nbsp; return unlinkLast(l);</b>
        <i>298</i>&nbsp; }
        <i>299</i>&nbsp;
        <i>300</i>&nbsp; /**
        <i>301</i>&nbsp; * Inserts the specified element at the beginning of this list.
        <i>302</i>&nbsp; *
        <i>303</i>&nbsp; * @param e the element to add
        <i>304</i>&nbsp; */
        <i>305</i>&nbsp; @Override
        <i>306</i>&nbsp; public void addFirst(E e) {
        <b class="nc"><i>307</i>&nbsp; linkFirst(e);</b>
        <b class="nc"><i>308</i>&nbsp; }</b>
        <i>309</i>&nbsp;
        <i>310</i>&nbsp; /**
        <i>311</i>&nbsp; * Appends the specified element to the end of this list.
        <i>312</i>&nbsp; *
        <i>313</i>&nbsp; * &lt;p&gt;This method is equivalent to {@link #add}.
        <i>314</i>&nbsp; *
        <i>315</i>&nbsp; * @param e the element to add
        <i>316</i>&nbsp; */
        <i>317</i>&nbsp; @Override
        <i>318</i>&nbsp; public void addLast(E e) {
        <b class="nc"><i>319</i>&nbsp; linkLast(e);</b>
        <b class="nc"><i>320</i>&nbsp; }</b>
        <i>321</i>&nbsp;
        <i>322</i>&nbsp; /**
        <i>323</i>&nbsp; * Returns {@code true} if this list contains the specified element.
        <i>324</i>&nbsp; * More formally, returns {@code true} if and only if this list contains
        <i>325</i>&nbsp; * at least one element {@code e} such that
        <i>326</i>&nbsp; * &lt;tt&gt;(o==null&amp;nbsp;?&amp;nbsp;e==null&amp;nbsp;:&amp;nbsp;o.equals(e))&lt;/tt&gt;.
        <i>327</i>&nbsp; *
        <i>328</i>&nbsp; * @param o element whose presence in this list is to be tested
        <i>329</i>&nbsp; * @return {@code true} if this list contains the specified element
        <i>330</i>&nbsp; */
        <i>331</i>&nbsp; @Override
        <i>332</i>&nbsp; public boolean contains(Object o) {
        <b class="nc"><i>333</i>&nbsp; return indexOf(o) != -1;</b>
        <i>334</i>&nbsp; }
        <i>335</i>&nbsp;
        <i>336</i>&nbsp; /**
        <i>337</i>&nbsp; * Returns the number of elements in this list.
        <i>338</i>&nbsp; *
        <i>339</i>&nbsp; * @return the number of elements in this list
        <i>340</i>&nbsp; */
        <i>341</i>&nbsp; @Override
        <i>342</i>&nbsp; public int size() {
        <b class="nc"><i>343</i>&nbsp; return size;</b>
        <i>344</i>&nbsp; }
        <i>345</i>&nbsp;
        <i>346</i>&nbsp; /**
        <i>347</i>&nbsp; * Appends the specified element to the end of this list.
        <i>348</i>&nbsp; *
        <i>349</i>&nbsp; * &lt;p&gt;This method is equivalent to {@link #addLast}.
        <i>350</i>&nbsp; *
        <i>351</i>&nbsp; * @param e element to be appended to this list
        <i>352</i>&nbsp; * @return {@code true} (as specified by {@link Collection#add})
        <i>353</i>&nbsp; */
        <i>354</i>&nbsp; @Override
        <i>355</i>&nbsp; public boolean add(E e) {
        <b class="fc"><i>356</i>&nbsp; linkLast(e);</b>
        <b class="fc"><i>357</i>&nbsp; return true;</b>
        <i>358</i>&nbsp; }
        <i>359</i>&nbsp;
        <i>360</i>&nbsp; /**
        <i>361</i>&nbsp; * Removes the first occurrence of the specified element from this list,
        <i>362</i>&nbsp; * if it is present. If this list does not contain the element, it is
        <i>363</i>&nbsp; * unchanged. More formally, removes the element with the lowest index
        <i>364</i>&nbsp; * {@code i} such that
        <i>365</i>&nbsp; * &lt;tt&gt;(o==null&amp;nbsp;?&amp;nbsp;get(i)==null&amp;nbsp;:&amp;nbsp;o.equals(get(i)))&lt;/tt&gt;
        <i>366</i>&nbsp; * (if such an element exists). Returns {@code true} if this list
        <i>367</i>&nbsp; * contained the specified element (or equivalently, if this list
        <i>368</i>&nbsp; * changed as a result of the call).
        <i>369</i>&nbsp; *
        <i>370</i>&nbsp; * @param o element to be removed from this list, if present
        <i>371</i>&nbsp; * @return {@code true} if this list contained the specified element
        <i>372</i>&nbsp; */
        <i>373</i>&nbsp; @Override
        <i>374</i>&nbsp; public boolean remove(Object o) {
        <b class="fc"><i>375</i>&nbsp; if (o == null) {</b>
        <b class="fc"><i>376</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="fc"><i>377</i>&nbsp; if (x.item == null) {</b>
        <b class="fc"><i>378</i>&nbsp; unlink(x);</b>
        <b class="fc"><i>379</i>&nbsp; return true;</b>
        <i>380</i>&nbsp; }
        <i>381</i>&nbsp; }
        <i>382</i>&nbsp; } else {
        <b class="fc"><i>383</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="fc"><i>384</i>&nbsp; if (o.equals(x.item)) {</b>
        <b class="fc"><i>385</i>&nbsp; unlink(x);</b>
        <b class="fc"><i>386</i>&nbsp; return true;</b>
        <i>387</i>&nbsp; }
        <i>388</i>&nbsp; }
        <i>389</i>&nbsp; }
        <b class="fc"><i>390</i>&nbsp; return false;</b>
        <i>391</i>&nbsp; }
        <i>392</i>&nbsp;
        <i>393</i>&nbsp; /**
        <i>394</i>&nbsp; * Appends all of the elements in the specified collection to the end of
        <i>395</i>&nbsp; * this list, in the order that they are returned by the specified
        <i>396</i>&nbsp; * collection&#39;s iterator. The behavior of this operation is undefined if
        <i>397</i>&nbsp; * the specified collection is modified while the operation is in
        <i>398</i>&nbsp; * progress. (Note that this will occur if the specified collection is
        <i>399</i>&nbsp; * this list, and it&#39;s nonempty.)
        <i>400</i>&nbsp; *
        <i>401</i>&nbsp; * @param c collection containing elements to be added to this list
        <i>402</i>&nbsp; * @return {@code true} if this list changed as a result of the call
        <i>403</i>&nbsp; * @throws NullPointerException if the specified collection is null
        <i>404</i>&nbsp; */
        <i>405</i>&nbsp; @Override
        <i>406</i>&nbsp; public boolean addAll(Collection&lt;? extends E&gt; c) {
        <b class="nc"><i>407</i>&nbsp; return addAll(size, c);</b>
        <i>408</i>&nbsp; }
        <i>409</i>&nbsp;
        <i>410</i>&nbsp; /**
        <i>411</i>&nbsp; * Inserts all of the elements in the specified collection into this
        <i>412</i>&nbsp; * list, starting at the specified position. Shifts the element
        <i>413</i>&nbsp; * currently at that position (if any) and any subsequent elements to
        <i>414</i>&nbsp; * the right (increases their indices). The new elements will appear
        <i>415</i>&nbsp; * in the list in the order that they are returned by the
        <i>416</i>&nbsp; * specified collection&#39;s iterator.
        <i>417</i>&nbsp; *
        <i>418</i>&nbsp; * @param index index at which to insert the first element
        <i>419</i>&nbsp; * from the specified collection
        <i>420</i>&nbsp; * @param c collection containing elements to be added to this list
        <i>421</i>&nbsp; * @return {@code true} if this list changed as a result of the call
        <i>422</i>&nbsp; * @throws IndexOutOfBoundsException {@inheritDoc}
        <i>423</i>&nbsp; * @throws NullPointerException if the specified collection is null
        <i>424</i>&nbsp; */
        <i>425</i>&nbsp; @Override
        <i>426</i>&nbsp; public boolean addAll(int index, Collection&lt;? extends E&gt; c) {
        <b class="nc"><i>427</i>&nbsp; checkPositionIndex(index);</b>
        <i>428</i>&nbsp;
        <b class="nc"><i>429</i>&nbsp; Object[] a = c.toArray();</b>
        <b class="nc"><i>430</i>&nbsp; int numNew = a.length;</b>
        <b class="nc"><i>431</i>&nbsp; if (numNew == 0) {</b>
        <b class="nc"><i>432</i>&nbsp; return false;</b>
        <i>433</i>&nbsp; }
        <i>434</i>&nbsp;
        <i>435</i>&nbsp; Node&lt;E&gt; pred, succ;
        <b class="nc"><i>436</i>&nbsp; if (index == size) {</b>
        <b class="nc"><i>437</i>&nbsp; succ = null;</b>
        <b class="nc"><i>438</i>&nbsp; pred = last;</b>
        <i>439</i>&nbsp; } else {
        <b class="nc"><i>440</i>&nbsp; succ = node(index);</b>
        <b class="nc"><i>441</i>&nbsp; pred = succ.prev;</b>
        <i>442</i>&nbsp; }
        <i>443</i>&nbsp;
        <b class="nc"><i>444</i>&nbsp; for (Object o : a) {</b>
        <b class="nc"><i>445</i>&nbsp; @SuppressWarnings(&quot;unchecked&quot;) E e = (E) o;</b>
        <b class="nc"><i>446</i>&nbsp; Node&lt;E&gt; newNode = new Node&lt;&gt;(pred, e, null);</b>
        <b class="nc"><i>447</i>&nbsp; if (pred == null) {</b>
        <b class="nc"><i>448</i>&nbsp; first = newNode;</b>
        <i>449</i>&nbsp; } else {
        <b class="nc"><i>450</i>&nbsp; pred.next = newNode;</b>
        <i>451</i>&nbsp; }
        <b class="nc"><i>452</i>&nbsp; pred = newNode;</b>
        <i>453</i>&nbsp; }
        <i>454</i>&nbsp;
        <b class="nc"><i>455</i>&nbsp; if (succ == null) {</b>
        <b class="nc"><i>456</i>&nbsp; last = pred;</b>
        <i>457</i>&nbsp; } else {
        <b class="nc"><i>458</i>&nbsp; pred.next = succ;</b>
        <b class="nc"><i>459</i>&nbsp; succ.prev = pred;</b>
        <i>460</i>&nbsp; }
        <i>461</i>&nbsp;
        <b class="nc"><i>462</i>&nbsp; size += numNew;</b>
        <b class="nc"><i>463</i>&nbsp; modCount++;</b>
        <b class="nc"><i>464</i>&nbsp; return true;</b>
        <i>465</i>&nbsp; }
        <i>466</i>&nbsp;
        <i>467</i>&nbsp;
        <i>468</i>&nbsp; // Positional Access Operations
        <i>469</i>&nbsp;
        <i>470</i>&nbsp; /**
        <i>471</i>&nbsp; * Removes all of the elements from this list.
        <i>472</i>&nbsp; * The list will be empty after this call returns.
        <i>473</i>&nbsp; */
        <i>474</i>&nbsp; @Override
        <i>475</i>&nbsp; public void clear() {
        <i>476</i>&nbsp; // Clearing all of the links between nodes is &quot;unnecessary&quot;, but:
        <i>477</i>&nbsp; // - helps a generational GC if the discarded nodes inhabit
        <i>478</i>&nbsp; // more than one generation
        <i>479</i>&nbsp; // - is sure to free memory even if there is a reachable Iterator
        <b class="nc"><i>480</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; ) {</b>
        <b class="nc"><i>481</i>&nbsp; Node&lt;E&gt; next = x.next;</b>
        <b class="nc"><i>482</i>&nbsp; x.item = null;</b>
        <b class="nc"><i>483</i>&nbsp; x.next = null;</b>
        <b class="nc"><i>484</i>&nbsp; x.prev = null;</b>
        <b class="nc"><i>485</i>&nbsp; x = next;</b>
        <b class="nc"><i>486</i>&nbsp; }</b>
        <b class="nc"><i>487</i>&nbsp; first = last = null;</b>
        <b class="nc"><i>488</i>&nbsp; size = 0;</b>
        <b class="nc"><i>489</i>&nbsp; modCount++;</b>
        <b class="nc"><i>490</i>&nbsp; }</b>
        <i>491</i>&nbsp;
        <i>492</i>&nbsp; /**
        <i>493</i>&nbsp; * Returns the element at the specified position in this list.
        <i>494</i>&nbsp; *
        <i>495</i>&nbsp; * @param index index of the element to return
        <i>496</i>&nbsp; * @return the element at the specified position in this list
        <i>497</i>&nbsp; * @throws IndexOutOfBoundsException {@inheritDoc}
        <i>498</i>&nbsp; */
        <i>499</i>&nbsp; @Override
        <i>500</i>&nbsp; public E get(int index) {
        <b class="nc"><i>501</i>&nbsp; checkElementIndex(index);</b>
        <b class="nc"><i>502</i>&nbsp; return node(index).item;</b>
        <i>503</i>&nbsp; }
        <i>504</i>&nbsp;
        <i>505</i>&nbsp; /**
        <i>506</i>&nbsp; * Replaces the element at the specified position in this list with the
        <i>507</i>&nbsp; * specified element.
        <i>508</i>&nbsp; *
        <i>509</i>&nbsp; * @param index index of the element to replace
        <i>510</i>&nbsp; * @param element element to be stored at the specified position
        <i>511</i>&nbsp; * @return the element previously at the specified position
        <i>512</i>&nbsp; * @throws IndexOutOfBoundsException {@inheritDoc}
        <i>513</i>&nbsp; */
        <i>514</i>&nbsp; @Override
        <i>515</i>&nbsp; public E set(int index, E element) {
        <b class="nc"><i>516</i>&nbsp; checkElementIndex(index);</b>
        <b class="nc"><i>517</i>&nbsp; Node&lt;E&gt; x = node(index);</b>
        <b class="nc"><i>518</i>&nbsp; E oldVal = x.item;</b>
        <b class="nc"><i>519</i>&nbsp; x.item = element;</b>
        <b class="nc"><i>520</i>&nbsp; return oldVal;</b>
        <i>521</i>&nbsp; }
        <i>522</i>&nbsp;
        <i>523</i>&nbsp; /**
        <i>524</i>&nbsp; * Inserts the specified element at the specified position in this list.
        <i>525</i>&nbsp; * Shifts the element currently at that position (if any) and any
        <i>526</i>&nbsp; * subsequent elements to the right (adds one to their indices).
        <i>527</i>&nbsp; *
        <i>528</i>&nbsp; * @param index index at which the specified element is to be inserted
        <i>529</i>&nbsp; * @param element element to be inserted
        <i>530</i>&nbsp; * @throws IndexOutOfBoundsException {@inheritDoc}
        <i>531</i>&nbsp; */
        <i>532</i>&nbsp; @Override
        <i>533</i>&nbsp; public void add(int index, E element) {
        <b class="nc"><i>534</i>&nbsp; checkPositionIndex(index);</b>
        <i>535</i>&nbsp;
        <b class="nc"><i>536</i>&nbsp; if (index == size) {</b>
        <b class="nc"><i>537</i>&nbsp; linkLast(element);</b>
        <i>538</i>&nbsp; } else {
        <b class="nc"><i>539</i>&nbsp; linkBefore(element, node(index));</b>
        <i>540</i>&nbsp; }
        <b class="nc"><i>541</i>&nbsp; }</b>
        <i>542</i>&nbsp;
        <i>543</i>&nbsp; /**
        <i>544</i>&nbsp; * Removes the element at the specified position in this list. Shifts any
        <i>545</i>&nbsp; * subsequent elements to the left (subtracts one from their indices).
        <i>546</i>&nbsp; * Returns the element that was removed from the list.
        <i>547</i>&nbsp; *
        <i>548</i>&nbsp; * @param index the index of the element to be removed
        <i>549</i>&nbsp; * @return the element previously at the specified position
        <i>550</i>&nbsp; * @throws IndexOutOfBoundsException {@inheritDoc}
        <i>551</i>&nbsp; */
        <i>552</i>&nbsp; @Override
        <i>553</i>&nbsp; public E remove(int index) {
        <b class="nc"><i>554</i>&nbsp; checkElementIndex(index);</b>
        <b class="nc"><i>555</i>&nbsp; return unlink(node(index));</b>
        <i>556</i>&nbsp; }
        <i>557</i>&nbsp;
        <i>558</i>&nbsp; /**
        <i>559</i>&nbsp; * Tells if the argument is the index of an existing element.
        <i>560</i>&nbsp; */
        <i>561</i>&nbsp; private boolean isElementIndex(int index) {
        <b class="nc"><i>562</i>&nbsp; return index &gt;= 0 &amp;&amp; index &lt; size;</b>
        <i>563</i>&nbsp; }
        <i>564</i>&nbsp;
        <i>565</i>&nbsp; /**
        <i>566</i>&nbsp; * Tells if the argument is the index of a valid position for an
        <i>567</i>&nbsp; * iterator or an add operation.
        <i>568</i>&nbsp; */
        <i>569</i>&nbsp; private boolean isPositionIndex(int index) {
        <b class="nc"><i>570</i>&nbsp; return index &gt;= 0 &amp;&amp; index &lt;= size;</b>
        <i>571</i>&nbsp; }
        <i>572</i>&nbsp;
        <i>573</i>&nbsp; /**
        <i>574</i>&nbsp; * Constructs an IndexOutOfBoundsException detail message.
        <i>575</i>&nbsp; * Of the many possible refactorings of the error handling code,
        <i>576</i>&nbsp; * this &quot;outlining&quot; performs best with both server and client VMs.
        <i>577</i>&nbsp; */
        <i>578</i>&nbsp; private String outOfBoundsMsg(int index) {
        <b class="nc"><i>579</i>&nbsp; return &quot;Index: &quot; + index + &quot;, Size: &quot; + size;</b>
        <i>580</i>&nbsp; }
        <i>581</i>&nbsp;
        <i>582</i>&nbsp; private void checkElementIndex(int index) {
        <b class="nc"><i>583</i>&nbsp; if (!isElementIndex(index)) {</b>
        <b class="nc"><i>584</i>&nbsp; throw new IndexOutOfBoundsException(outOfBoundsMsg(index));</b>
        <i>585</i>&nbsp; }
        <b class="nc"><i>586</i>&nbsp; }</b>
        <i>587</i>&nbsp;
        <i>588</i>&nbsp; private void checkPositionIndex(int index) {
        <b class="nc"><i>589</i>&nbsp; if (!isPositionIndex(index)) {</b>
        <b class="nc"><i>590</i>&nbsp; throw new IndexOutOfBoundsException(outOfBoundsMsg(index));</b>
        <i>591</i>&nbsp; }
        <b class="nc"><i>592</i>&nbsp; }</b>
        <i>593</i>&nbsp;
        <i>594</i>&nbsp; // Search Operations
        <i>595</i>&nbsp;
        <i>596</i>&nbsp; /**
        <i>597</i>&nbsp; * Returns the (non-null) Node at the specified element index.
        <i>598</i>&nbsp; */
        <i>599</i>&nbsp; Node&lt;E&gt; node(int index) {
        <i>600</i>&nbsp; // assert isElementIndex(index);
        <i>601</i>&nbsp;
        <i>602</i>&nbsp; Node&lt;E&gt; x;
        <b class="nc"><i>603</i>&nbsp; if (index &lt; (size &gt;&gt; 1)) {</b>
        <b class="nc"><i>604</i>&nbsp; x = first;</b>
        <b class="nc"><i>605</i>&nbsp; for (int i = 0; i &lt; index; i++) {</b>
        <b class="nc"><i>606</i>&nbsp; x = x.next;</b>
        <i>607</i>&nbsp; }
        <i>608</i>&nbsp; } else {
        <b class="nc"><i>609</i>&nbsp; x = last;</b>
        <b class="nc"><i>610</i>&nbsp; for (int i = size - 1; i &gt; index; i--) {</b>
        <b class="nc"><i>611</i>&nbsp; x = x.prev;</b>
        <i>612</i>&nbsp; }
        <i>613</i>&nbsp; }
        <b class="nc"><i>614</i>&nbsp; return x;</b>
        <i>615</i>&nbsp; }
        <i>616</i>&nbsp;
        <i>617</i>&nbsp; /**
        <i>618</i>&nbsp; * Returns the index of the first occurrence of the specified element
        <i>619</i>&nbsp; * in this list, or -1 if this list does not contain the element.
        <i>620</i>&nbsp; * More formally, returns the lowest index {@code i} such that
        <i>621</i>&nbsp; * &lt;tt&gt;(o==null&amp;nbsp;?&amp;nbsp;get(i)==null&amp;nbsp;:&amp;nbsp;o.equals(get(i)))&lt;/tt&gt;,
        <i>622</i>&nbsp; * or -1 if there is no such index.
        <i>623</i>&nbsp; *
        <i>624</i>&nbsp; * @param o element to search for
        <i>625</i>&nbsp; * @return the index of the first occurrence of the specified element in
        <i>626</i>&nbsp; * this list, or -1 if this list does not contain the element
        <i>627</i>&nbsp; */
        <i>628</i>&nbsp; @Override
        <i>629</i>&nbsp; public int indexOf(Object o) {
        <b class="nc"><i>630</i>&nbsp; int index = 0;</b>
        <b class="nc"><i>631</i>&nbsp; if (o == null) {</b>
        <b class="nc"><i>632</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="nc"><i>633</i>&nbsp; if (x.item == null) {</b>
        <b class="nc"><i>634</i>&nbsp; return index;</b>
        <i>635</i>&nbsp; }
        <b class="nc"><i>636</i>&nbsp; index++;</b>
        <i>637</i>&nbsp; }
        <i>638</i>&nbsp; } else {
        <b class="nc"><i>639</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="nc"><i>640</i>&nbsp; if (o.equals(x.item)) {</b>
        <b class="nc"><i>641</i>&nbsp; return index;</b>
        <i>642</i>&nbsp; }
        <b class="nc"><i>643</i>&nbsp; index++;</b>
        <i>644</i>&nbsp; }
        <i>645</i>&nbsp; }
        <b class="nc"><i>646</i>&nbsp; return -1;</b>
        <i>647</i>&nbsp; }
        <i>648</i>&nbsp;
        <i>649</i>&nbsp; // Queue operations.
        <i>650</i>&nbsp;
        <i>651</i>&nbsp; /**
        <i>652</i>&nbsp; * Returns the index of the last occurrence of the specified element
        <i>653</i>&nbsp; * in this list, or -1 if this list does not contain the element.
        <i>654</i>&nbsp; * More formally, returns the highest index {@code i} such that
        <i>655</i>&nbsp; * &lt;tt&gt;(o==null&amp;nbsp;?&amp;nbsp;get(i)==null&amp;nbsp;:&amp;nbsp;o.equals(get(i)))&lt;/tt&gt;,
        <i>656</i>&nbsp; * or -1 if there is no such index.
        <i>657</i>&nbsp; *
        <i>658</i>&nbsp; * @param o element to search for
        <i>659</i>&nbsp; * @return the index of the last occurrence of the specified element in
        <i>660</i>&nbsp; * this list, or -1 if this list does not contain the element
        <i>661</i>&nbsp; */
        <i>662</i>&nbsp; @Override
        <i>663</i>&nbsp; public int lastIndexOf(Object o) {
        <b class="nc"><i>664</i>&nbsp; int index = size;</b>
        <b class="nc"><i>665</i>&nbsp; if (o == null) {</b>
        <b class="nc"><i>666</i>&nbsp; for (Node&lt;E&gt; x = last; x != null; x = x.prev) {</b>
        <b class="nc"><i>667</i>&nbsp; index--;</b>
        <b class="nc"><i>668</i>&nbsp; if (x.item == null) {</b>
        <b class="nc"><i>669</i>&nbsp; return index;</b>
        <i>670</i>&nbsp; }
        <i>671</i>&nbsp; }
        <i>672</i>&nbsp; } else {
        <b class="nc"><i>673</i>&nbsp; for (Node&lt;E&gt; x = last; x != null; x = x.prev) {</b>
        <b class="nc"><i>674</i>&nbsp; index--;</b>
        <b class="nc"><i>675</i>&nbsp; if (o.equals(x.item)) {</b>
        <b class="nc"><i>676</i>&nbsp; return index;</b>
        <i>677</i>&nbsp; }
        <i>678</i>&nbsp; }
        <i>679</i>&nbsp; }
        <b class="nc"><i>680</i>&nbsp; return -1;</b>
        <i>681</i>&nbsp; }
        <i>682</i>&nbsp;
        <i>683</i>&nbsp; /**
        <i>684</i>&nbsp; * Retrieves, but does not remove, the head (first element) of this list.
        <i>685</i>&nbsp; *
        <i>686</i>&nbsp; * @return the head of this list, or {@code null} if this list is empty
        <i>687</i>&nbsp; * @since 1.5
        <i>688</i>&nbsp; */
        <i>689</i>&nbsp; @Override
        <i>690</i>&nbsp; public E peek() {
        <b class="nc"><i>691</i>&nbsp; final Node&lt;E&gt; f = first;</b>
        <b class="nc"><i>692</i>&nbsp; return (f == null) ? null : f.item;</b>
        <i>693</i>&nbsp; }
        <i>694</i>&nbsp;
        <i>695</i>&nbsp; /**
        <i>696</i>&nbsp; * Retrieves, but does not remove, the head (first element) of this list.
        <i>697</i>&nbsp; *
        <i>698</i>&nbsp; * @return the head of this list
        <i>699</i>&nbsp; * @throws NoSuchElementException if this list is empty
        <i>700</i>&nbsp; * @since 1.5
        <i>701</i>&nbsp; */
        <i>702</i>&nbsp; @Override
        <i>703</i>&nbsp; public E element() {
        <b class="nc"><i>704</i>&nbsp; return getFirst();</b>
        <i>705</i>&nbsp; }
        <i>706</i>&nbsp;
        <i>707</i>&nbsp; /**
        <i>708</i>&nbsp; * Retrieves and removes the head (first element) of this list.
        <i>709</i>&nbsp; *
        <i>710</i>&nbsp; * @return the head of this list, or {@code null} if this list is empty
        <i>711</i>&nbsp; * @since 1.5
        <i>712</i>&nbsp; */
        <i>713</i>&nbsp; @Override
        <i>714</i>&nbsp; public E poll() {
        <b class="nc"><i>715</i>&nbsp; final Node&lt;E&gt; f = first;</b>
        <b class="nc"><i>716</i>&nbsp; return (f == null) ? null : unlinkFirst(f);</b>
        <i>717</i>&nbsp; }
        <i>718</i>&nbsp;
        <i>719</i>&nbsp; /**
        <i>720</i>&nbsp; * Retrieves and removes the head (first element) of this list.
        <i>721</i>&nbsp; *
        <i>722</i>&nbsp; * @return the head of this list
        <i>723</i>&nbsp; * @throws NoSuchElementException if this list is empty
        <i>724</i>&nbsp; * @since 1.5
        <i>725</i>&nbsp; */
        <i>726</i>&nbsp; @Override
        <i>727</i>&nbsp; public E remove() {
        <b class="nc"><i>728</i>&nbsp; return removeFirst();</b>
        <i>729</i>&nbsp; }
        <i>730</i>&nbsp;
        <i>731</i>&nbsp; // Deque operations
        <i>732</i>&nbsp;
        <i>733</i>&nbsp; /**
        <i>734</i>&nbsp; * Adds the specified element as the tail (last element) of this list.
        <i>735</i>&nbsp; *
        <i>736</i>&nbsp; * @param e the element to add
        <i>737</i>&nbsp; * @return {@code true} (as specified by {@link Queue#offer})
        <i>738</i>&nbsp; * @since 1.5
        <i>739</i>&nbsp; */
        <i>740</i>&nbsp; @Override
        <i>741</i>&nbsp; public boolean offer(E e) {
        <b class="nc"><i>742</i>&nbsp; return add(e);</b>
        <i>743</i>&nbsp; }
        <i>744</i>&nbsp;
        <i>745</i>&nbsp; /**
        <i>746</i>&nbsp; * Inserts the specified element at the front of this list.
        <i>747</i>&nbsp; *
        <i>748</i>&nbsp; * @param e the element to insert
        <i>749</i>&nbsp; * @return {@code true} (as specified by {@link Deque#offerFirst})
        <i>750</i>&nbsp; * @since 1.6
        <i>751</i>&nbsp; */
        <i>752</i>&nbsp; @Override
        <i>753</i>&nbsp; public boolean offerFirst(E e) {
        <b class="nc"><i>754</i>&nbsp; addFirst(e);</b>
        <b class="nc"><i>755</i>&nbsp; return true;</b>
        <i>756</i>&nbsp; }
        <i>757</i>&nbsp;
        <i>758</i>&nbsp; /**
        <i>759</i>&nbsp; * Inserts the specified element at the end of this list.
        <i>760</i>&nbsp; *
        <i>761</i>&nbsp; * @param e the element to insert
        <i>762</i>&nbsp; * @return {@code true} (as specified by {@link Deque#offerLast})
        <i>763</i>&nbsp; * @since 1.6
        <i>764</i>&nbsp; */
        <i>765</i>&nbsp; @Override
        <i>766</i>&nbsp; public boolean offerLast(E e) {
        <b class="nc"><i>767</i>&nbsp; addLast(e);</b>
        <b class="nc"><i>768</i>&nbsp; return true;</b>
        <i>769</i>&nbsp; }
        <i>770</i>&nbsp;
        <i>771</i>&nbsp; /**
        <i>772</i>&nbsp; * Retrieves, but does not remove, the first element of this list,
        <i>773</i>&nbsp; * or returns {@code null} if this list is empty.
        <i>774</i>&nbsp; *
        <i>775</i>&nbsp; * @return the first element of this list, or {@code null}
        <i>776</i>&nbsp; * if this list is empty
        <i>777</i>&nbsp; * @since 1.6
        <i>778</i>&nbsp; */
        <i>779</i>&nbsp; @Override
        <i>780</i>&nbsp; public E peekFirst() {
        <b class="nc"><i>781</i>&nbsp; final Node&lt;E&gt; f = first;</b>
        <b class="nc"><i>782</i>&nbsp; return (f == null) ? null : f.item;</b>
        <i>783</i>&nbsp; }
        <i>784</i>&nbsp;
        <i>785</i>&nbsp; /**
        <i>786</i>&nbsp; * Retrieves, but does not remove, the last element of this list,
        <i>787</i>&nbsp; * or returns {@code null} if this list is empty.
        <i>788</i>&nbsp; *
        <i>789</i>&nbsp; * @return the last element of this list, or {@code null}
        <i>790</i>&nbsp; * if this list is empty
        <i>791</i>&nbsp; * @since 1.6
        <i>792</i>&nbsp; */
        <i>793</i>&nbsp; @Override
        <i>794</i>&nbsp; public E peekLast() {
        <b class="nc"><i>795</i>&nbsp; final Node&lt;E&gt; l = last;</b>
        <b class="nc"><i>796</i>&nbsp; return (l == null) ? null : l.item;</b>
        <i>797</i>&nbsp; }
        <i>798</i>&nbsp;
        <i>799</i>&nbsp; /**
        <i>800</i>&nbsp; * Retrieves and removes the first element of this list,
        <i>801</i>&nbsp; * or returns {@code null} if this list is empty.
        <i>802</i>&nbsp; *
        <i>803</i>&nbsp; * @return the first element of this list, or {@code null} if
        <i>804</i>&nbsp; * this list is empty
        <i>805</i>&nbsp; * @since 1.6
        <i>806</i>&nbsp; */
        <i>807</i>&nbsp; @Override
        <i>808</i>&nbsp; public E pollFirst() {
        <b class="nc"><i>809</i>&nbsp; final Node&lt;E&gt; f = first;</b>
        <b class="nc"><i>810</i>&nbsp; return (f == null) ? null : unlinkFirst(f);</b>
        <i>811</i>&nbsp; }
        <i>812</i>&nbsp;
        <i>813</i>&nbsp; /**
        <i>814</i>&nbsp; * Retrieves and removes the last element of this list,
        <i>815</i>&nbsp; * or returns {@code null} if this list is empty.
        <i>816</i>&nbsp; *
        <i>817</i>&nbsp; * @return the last element of this list, or {@code null} if
        <i>818</i>&nbsp; * this list is empty
        <i>819</i>&nbsp; * @since 1.6
        <i>820</i>&nbsp; */
        <i>821</i>&nbsp; @Override
        <i>822</i>&nbsp; public E pollLast() {
        <b class="nc"><i>823</i>&nbsp; final Node&lt;E&gt; l = last;</b>
        <b class="nc"><i>824</i>&nbsp; return (l == null) ? null : unlinkLast(l);</b>
        <i>825</i>&nbsp; }
        <i>826</i>&nbsp;
        <i>827</i>&nbsp; /**
        <i>828</i>&nbsp; * Pushes an element onto the stack represented by this list. In other
        <i>829</i>&nbsp; * words, inserts the element at the front of this list.
        <i>830</i>&nbsp; *
        <i>831</i>&nbsp; * &lt;p&gt;This method is equivalent to {@link #addFirst}.
        <i>832</i>&nbsp; *
        <i>833</i>&nbsp; * @param e the element to push
        <i>834</i>&nbsp; * @since 1.6
        <i>835</i>&nbsp; */
        <i>836</i>&nbsp; @Override
        <i>837</i>&nbsp; public void push(E e) {
        <b class="nc"><i>838</i>&nbsp; addFirst(e);</b>
        <b class="nc"><i>839</i>&nbsp; }</b>
        <i>840</i>&nbsp;
        <i>841</i>&nbsp; /**
        <i>842</i>&nbsp; * Pops an element from the stack represented by this list. In other
        <i>843</i>&nbsp; * words, removes and returns the first element of this list.
        <i>844</i>&nbsp; *
        <i>845</i>&nbsp; * &lt;p&gt;This method is equivalent to {@link #removeFirst()}.
        <i>846</i>&nbsp; *
        <i>847</i>&nbsp; * @return the element at the front of this list (which is the top
        <i>848</i>&nbsp; * of the stack represented by this list)
        <i>849</i>&nbsp; * @throws NoSuchElementException if this list is empty
        <i>850</i>&nbsp; * @since 1.6
        <i>851</i>&nbsp; */
        <i>852</i>&nbsp; @Override
        <i>853</i>&nbsp; public E pop() {
        <b class="nc"><i>854</i>&nbsp; return removeFirst();</b>
        <i>855</i>&nbsp; }
        <i>856</i>&nbsp;
        <i>857</i>&nbsp; /**
        <i>858</i>&nbsp; * Removes the first occurrence of the specified element in this
        <i>859</i>&nbsp; * list (when traversing the list from head to tail). If the list
        <i>860</i>&nbsp; * does not contain the element, it is unchanged.
        <i>861</i>&nbsp; *
        <i>862</i>&nbsp; * @param o element to be removed from this list, if present
        <i>863</i>&nbsp; * @return {@code true} if the list contained the specified element
        <i>864</i>&nbsp; * @since 1.6
        <i>865</i>&nbsp; */
        <i>866</i>&nbsp; @Override
        <i>867</i>&nbsp; public boolean removeFirstOccurrence(Object o) {
        <b class="nc"><i>868</i>&nbsp; return remove(o);</b>
        <i>869</i>&nbsp; }
        <i>870</i>&nbsp;
        <i>871</i>&nbsp; /**
        <i>872</i>&nbsp; * Removes the last occurrence of the specified element in this
        <i>873</i>&nbsp; * list (when traversing the list from head to tail). If the list
        <i>874</i>&nbsp; * does not contain the element, it is unchanged.
        <i>875</i>&nbsp; *
        <i>876</i>&nbsp; * @param o element to be removed from this list, if present
        <i>877</i>&nbsp; * @return {@code true} if the list contained the specified element
        <i>878</i>&nbsp; * @since 1.6
        <i>879</i>&nbsp; */
        <i>880</i>&nbsp; @Override
        <i>881</i>&nbsp; public boolean removeLastOccurrence(Object o) {
        <b class="nc"><i>882</i>&nbsp; if (o == null) {</b>
        <b class="nc"><i>883</i>&nbsp; for (Node&lt;E&gt; x = last; x != null; x = x.prev) {</b>
        <b class="nc"><i>884</i>&nbsp; if (x.item == null) {</b>
        <b class="nc"><i>885</i>&nbsp; unlink(x);</b>
        <b class="nc"><i>886</i>&nbsp; return true;</b>
        <i>887</i>&nbsp; }
        <i>888</i>&nbsp; }
        <i>889</i>&nbsp; } else {
        <b class="nc"><i>890</i>&nbsp; for (Node&lt;E&gt; x = last; x != null; x = x.prev) {</b>
        <b class="nc"><i>891</i>&nbsp; if (o.equals(x.item)) {</b>
        <b class="nc"><i>892</i>&nbsp; unlink(x);</b>
        <b class="nc"><i>893</i>&nbsp; return true;</b>
        <i>894</i>&nbsp; }
        <i>895</i>&nbsp; }
        <i>896</i>&nbsp; }
        <b class="nc"><i>897</i>&nbsp; return false;</b>
        <i>898</i>&nbsp; }
        <i>899</i>&nbsp;
        <i>900</i>&nbsp; /**
        <i>901</i>&nbsp; * Returns a list-iterator of the elements in this list (in proper
        <i>902</i>&nbsp; * sequence), starting at the specified position in the list.
        <i>903</i>&nbsp; * Obeys the general contract of {@code List.listIterator(int)}.&lt;p&gt;
        <i>904</i>&nbsp; * &lt;p&gt;
        <i>905</i>&nbsp; * The list-iterator is &lt;i&gt;fail-fast&lt;/i&gt;: if the list is structurally
        <i>906</i>&nbsp; * modified at any time after the Iterator is created, in any way except
        <i>907</i>&nbsp; * through the list-iterator&#39;s own {@code remove} or {@code add}
        <i>908</i>&nbsp; * methods, the list-iterator will throw a
        <i>909</i>&nbsp; * {@code ConcurrentModificationException}. Thus, in the face of
        <i>910</i>&nbsp; * concurrent modification, the iterator fails quickly and cleanly, rather
        <i>911</i>&nbsp; * than risking arbitrary, non-deterministic behavior at an undetermined
        <i>912</i>&nbsp; * time in the future.
        <i>913</i>&nbsp; *
        <i>914</i>&nbsp; * @param index index of the first element to be returned from the
        <i>915</i>&nbsp; * list-iterator (by a call to {@code next})
        <i>916</i>&nbsp; * @return a ListIterator of the elements in this list (in proper
        <i>917</i>&nbsp; * sequence), starting at the specified position in the list
        <i>918</i>&nbsp; * @throws IndexOutOfBoundsException {@inheritDoc}
        <i>919</i>&nbsp; * @see List#listIterator(int)
        <i>920</i>&nbsp; */
        <i>921</i>&nbsp; @Override
        <i>922</i>&nbsp; public ListIterator&lt;E&gt; listIterator(int index) {
        <b class="nc"><i>923</i>&nbsp; checkPositionIndex(index);</b>
        <b class="nc"><i>924</i>&nbsp; return new ListItr(index);</b>
        <i>925</i>&nbsp; }
        <i>926</i>&nbsp;
        <i>927</i>&nbsp; /**
        <i>928</i>&nbsp; * @since 1.6
        <i>929</i>&nbsp; */
        <i>930</i>&nbsp; @Override
        <i>931</i>&nbsp; public Iterator&lt;E&gt; descendingIterator() {
        <b class="nc"><i>932</i>&nbsp; return new DescendingIterator();</b>
        <i>933</i>&nbsp; }
        <i>934</i>&nbsp;
        <i>935</i>&nbsp; @SuppressWarnings(&quot;unchecked&quot;)
        <i>936</i>&nbsp; private LinkedList&lt;E&gt; superClone() {
        <i>937</i>&nbsp; try {
        <b class="nc"><i>938</i>&nbsp; return (LinkedList&lt;E&gt;) super.clone();</b>
        <b class="nc"><i>939</i>&nbsp; } catch (CloneNotSupportedException e) {</b>
        <b class="nc"><i>940</i>&nbsp; throw new InternalError(e);</b>
        <i>941</i>&nbsp; }
        <i>942</i>&nbsp; }
        <i>943</i>&nbsp;
        <i>944</i>&nbsp; /**
        <i>945</i>&nbsp; * Returns a shallow copy of this {@code demo.mimic.LinkedList}. (The elements
        <i>946</i>&nbsp; * themselves are not cloned.)
        <i>947</i>&nbsp; *
        <i>948</i>&nbsp; * @return a shallow copy of this {@code demo.mimic.LinkedList} instance
        <i>949</i>&nbsp; */
        <i>950</i>&nbsp; @Override
        <i>951</i>&nbsp; public Object clone() {
        <b class="nc"><i>952</i>&nbsp; LinkedList&lt;E&gt; clone = superClone();</b>
        <i>953</i>&nbsp;
        <i>954</i>&nbsp; // Put clone into &quot;virgin&quot; state
        <b class="nc"><i>955</i>&nbsp; clone.first = clone.last = null;</b>
        <b class="nc"><i>956</i>&nbsp; clone.size = 0;</b>
        <b class="nc"><i>957</i>&nbsp; clone.modCount = 0;</b>
        <i>958</i>&nbsp;
        <i>959</i>&nbsp; // Initialize clone with our elements
        <b class="nc"><i>960</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="nc"><i>961</i>&nbsp; clone.add(x.item);</b>
        <i>962</i>&nbsp; }
        <i>963</i>&nbsp;
        <b class="nc"><i>964</i>&nbsp; return clone;</b>
        <i>965</i>&nbsp; }
        <i>966</i>&nbsp;
        <i>967</i>&nbsp; /**
        <i>968</i>&nbsp; * Returns an array containing all of the elements in this list
        <i>969</i>&nbsp; * in proper sequence (from first to last element).
        <i>970</i>&nbsp; *
        <i>971</i>&nbsp; * &lt;p&gt;The returned array will be &quot;safe&quot; in that no references to it are
        <i>972</i>&nbsp; * maintained by this list. (In other words, this method must allocate
        <i>973</i>&nbsp; * a new array). The caller is thus free to modify the returned array.
        <i>974</i>&nbsp; *
        <i>975</i>&nbsp; * &lt;p&gt;This method acts as bridge between array-based and collection-based
        <i>976</i>&nbsp; * APIs.
        <i>977</i>&nbsp; *
        <i>978</i>&nbsp; * @return an array containing all of the elements in this list
        <i>979</i>&nbsp; * in proper sequence
        <i>980</i>&nbsp; */
        <i>981</i>&nbsp; @Override
        <i>982</i>&nbsp; public Object[] toArray() {
        <b class="nc"><i>983</i>&nbsp; Object[] result = new Object[size];</b>
        <b class="nc"><i>984</i>&nbsp; int i = 0;</b>
        <b class="nc"><i>985</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="nc"><i>986</i>&nbsp; result[i++] = x.item;</b>
        <i>987</i>&nbsp; }
        <b class="nc"><i>988</i>&nbsp; return result;</b>
        <i>989</i>&nbsp; }
        <i>990</i>&nbsp;
        <i>991</i>&nbsp; /**
        <i>992</i>&nbsp; * Returns an array containing all of the elements in this list in
        <i>993</i>&nbsp; * proper sequence (from first to last element); the runtime type of
        <i>994</i>&nbsp; * the returned array is that of the specified array. If the list fits
        <i>995</i>&nbsp; * in the specified array, it is returned therein. Otherwise, a new
        <i>996</i>&nbsp; * array is allocated with the runtime type of the specified array and
        <i>997</i>&nbsp; * the size of this list.
        <i>998</i>&nbsp; *
        <i>999</i>&nbsp; * &lt;p&gt;If the list fits in the specified array with room to spare (i.e.,
        <i>1000</i>&nbsp; * the array has more elements than the list), the element in the array
        <i>1001</i>&nbsp; * immediately following the end of the list is set to {@code null}.
        <i>1002</i>&nbsp; * (This is useful in determining the length of the list &lt;i&gt;only&lt;/i&gt; if
        <i>1003</i>&nbsp; * the caller knows that the list does not contain any null elements.)
        <i>1004</i>&nbsp; *
        <i>1005</i>&nbsp; * &lt;p&gt;Like the {@link #toArray()} method, this method acts as bridge between
        <i>1006</i>&nbsp; * array-based and collection-based APIs. Further, this method allows
        <i>1007</i>&nbsp; * precise control over the runtime type of the output array, and may,
        <i>1008</i>&nbsp; * under certain circumstances, be used to save allocation costs.
        <i>1009</i>&nbsp; *
        <i>1010</i>&nbsp; * &lt;p&gt;Suppose {@code x} is a list known to contain only strings.
        <i>1011</i>&nbsp; * The following code can be used to dump the list into a newly
        <i>1012</i>&nbsp; * allocated array of {@code String}:
        <i>1013</i>&nbsp; *
        <i>1014</i>&nbsp; * &lt;pre&gt;
        <i>1015</i>&nbsp; * String[] y = x.toArray(new String[0]);&lt;/pre&gt;
        <i>1016</i>&nbsp; * &lt;p&gt;
        <i>1017</i>&nbsp; * Note that {@code toArray(new Object[0])} is identical in function to
        <i>1018</i>&nbsp; * {@code toArray()}.
        <i>1019</i>&nbsp; *
        <i>1020</i>&nbsp; * @param a the array into which the elements of the list are to
        <i>1021</i>&nbsp; * be stored, if it is big enough; otherwise, a new array of the
        <i>1022</i>&nbsp; * same runtime type is allocated for this purpose.
        <i>1023</i>&nbsp; * @return an array containing the elements of the list
        <i>1024</i>&nbsp; * @throws ArrayStoreException if the runtime type of the specified array
        <i>1025</i>&nbsp; * is not a supertype of the runtime type of every element in
        <i>1026</i>&nbsp; * this list
        <i>1027</i>&nbsp; * @throws NullPointerException if the specified array is null
        <i>1028</i>&nbsp; */
        <i>1029</i>&nbsp; @Override
        <i>1030</i>&nbsp; @SuppressWarnings(&quot;unchecked&quot;)
        <i>1031</i>&nbsp; public &lt;T&gt; T[] toArray(T[] a) {
        <b class="nc"><i>1032</i>&nbsp; if (a.length &lt; size) {</b>
        <b class="nc"><i>1033</i>&nbsp; a = (T[]) java.lang.reflect.Array.newInstance(</b>
        <b class="nc"><i>1034</i>&nbsp; a.getClass().getComponentType(), size);</b>
        <i>1035</i>&nbsp; }
        <b class="nc"><i>1036</i>&nbsp; int i = 0;</b>
        <b class="nc"><i>1037</i>&nbsp; Object[] result = a;</b>
        <b class="nc"><i>1038</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="nc"><i>1039</i>&nbsp; result[i++] = x.item;</b>
        <i>1040</i>&nbsp; }
        <i>1041</i>&nbsp;
        <b class="nc"><i>1042</i>&nbsp; if (a.length &gt; size) {</b>
        <b class="nc"><i>1043</i>&nbsp; a[size] = null;</b>
        <i>1044</i>&nbsp; }
        <i>1045</i>&nbsp;
        <b class="nc"><i>1046</i>&nbsp; return a;</b>
        <i>1047</i>&nbsp; }
        <i>1048</i>&nbsp;
        <i>1049</i>&nbsp; /**
        <i>1050</i>&nbsp; * Saves the state of this {@code demo.mimic.LinkedList} instance to a stream
        <i>1051</i>&nbsp; * (that is, serializes it).
        <i>1052</i>&nbsp; *
        <i>1053</i>&nbsp; * @serialData The size of the list (the number of elements it
        <i>1054</i>&nbsp; * contains) is emitted (int), followed by all of its
        <i>1055</i>&nbsp; * elements (each an Object) in the proper order.
        <i>1056</i>&nbsp; */
        <i>1057</i>&nbsp; private void writeObject(java.io.ObjectOutputStream s)
        <i>1058</i>&nbsp; throws java.io.IOException {
        <i>1059</i>&nbsp; // Write out any hidden serialization magic
        <b class="nc"><i>1060</i>&nbsp; s.defaultWriteObject();</b>
        <i>1061</i>&nbsp;
        <i>1062</i>&nbsp; // Write out size
        <b class="nc"><i>1063</i>&nbsp; s.writeInt(size);</b>
        <i>1064</i>&nbsp;
        <i>1065</i>&nbsp; // Write out all elements in the proper order.
        <b class="nc"><i>1066</i>&nbsp; for (Node&lt;E&gt; x = first; x != null; x = x.next) {</b>
        <b class="nc"><i>1067</i>&nbsp; s.writeObject(x.item);</b>
        <i>1068</i>&nbsp; }
        <b class="nc"><i>1069</i>&nbsp; }</b>
        <i>1070</i>&nbsp;
        <i>1071</i>&nbsp; /**
        <i>1072</i>&nbsp; * Reconstitutes this {@code demo.mimic.LinkedList} instance from a stream
        <i>1073</i>&nbsp; * (that is, deserializes it).
        <i>1074</i>&nbsp; */
        <i>1075</i>&nbsp; @SuppressWarnings(&quot;unchecked&quot;)
        <i>1076</i>&nbsp; private void readObject(java.io.ObjectInputStream s)
        <i>1077</i>&nbsp; throws java.io.IOException, ClassNotFoundException {
        <i>1078</i>&nbsp; // Read in any hidden serialization magic
        <b class="nc"><i>1079</i>&nbsp; s.defaultReadObject();</b>
        <i>1080</i>&nbsp;
        <i>1081</i>&nbsp; // Read in size
        <b class="nc"><i>1082</i>&nbsp; int size = s.readInt();</b>
        <i>1083</i>&nbsp;
        <i>1084</i>&nbsp; // Read in all elements in the proper order.
        <b class="nc"><i>1085</i>&nbsp; for (int i = 0; i &lt; size; i++) {</b>
        <b class="nc"><i>1086</i>&nbsp; linkLast((E) s.readObject());</b>
        <i>1087</i>&nbsp; }
        <b class="nc"><i>1088</i>&nbsp; }</b>
        <i>1089</i>&nbsp;
        <i>1090</i>&nbsp; /**
        <i>1091</i>&nbsp; * Creates a &lt;em&gt;&lt;a href=&quot;Spliterator.html#binding&quot;&gt;late-binding&lt;/a&gt;&lt;/em&gt;
        <i>1092</i>&nbsp; * and &lt;em&gt;fail-fast&lt;/em&gt; {@link Spliterator} over the elements in this
        <i>1093</i>&nbsp; * list.
        <i>1094</i>&nbsp; *
        <i>1095</i>&nbsp; * &lt;p&gt;The {@code Spliterator} reports {@link Spliterator#SIZED} and
        <i>1096</i>&nbsp; * {@link Spliterator#ORDERED}. Overriding implementations should document
        <i>1097</i>&nbsp; * the reporting of additional characteristic values.
        <i>1098</i>&nbsp; *
        <i>1099</i>&nbsp; * @return a {@code Spliterator} over the elements in this list
        <i>1100</i>&nbsp; * @implNote The {@code Spliterator} additionally reports {@link Spliterator#SUBSIZED}
        <i>1101</i>&nbsp; * and implements {@code trySplit} to permit limited parallelism..
        <i>1102</i>&nbsp; * @since 1.8
        <i>1103</i>&nbsp; */
        <i>1104</i>&nbsp; @Override
        <i>1105</i>&nbsp; public Spliterator&lt;E&gt; spliterator() {
        <b class="nc"><i>1106</i>&nbsp; return new LLSpliterator&lt;&gt;(this, -1, 0);</b>
        <i>1107</i>&nbsp; }
        <i>1108</i>&nbsp;
        <i>1109</i>&nbsp; private static class Node&lt;E&gt; {
        <i>1110</i>&nbsp; E item;
        <i>1111</i>&nbsp; Node&lt;E&gt; next;
        <i>1112</i>&nbsp; Node&lt;E&gt; prev;
        <i>1113</i>&nbsp;
        <b class="fc"><i>1114</i>&nbsp; Node(Node&lt;E&gt; prev, E element, Node&lt;E&gt; next) {</b>
        <b class="fc"><i>1115</i>&nbsp; this.item = element;</b>
        <b class="fc"><i>1116</i>&nbsp; this.next = next;</b>
        <b class="fc"><i>1117</i>&nbsp; this.prev = prev;</b>
        <b class="fc"><i>1118</i>&nbsp; }</b>
        <i>1119</i>&nbsp; }
        <i>1120</i>&nbsp;
        <i>1121</i>&nbsp; /**
        <i>1122</i>&nbsp; * A customized variant of Spliterators.IteratorSpliterator
        <i>1123</i>&nbsp; */
        <i>1124</i>&nbsp; static final class LLSpliterator&lt;E&gt; implements Spliterator&lt;E&gt; {
        <i>1125</i>&nbsp; static final int BATCH_UNIT = 1 &lt;&lt; 10; // batch array size increment
        <i>1126</i>&nbsp; static final int MAX_BATCH = 1 &lt;&lt; 25; // max batch array size;
        <i>1127</i>&nbsp; final LinkedList&lt;E&gt; list; // null OK unless traversed
        <i>1128</i>&nbsp; Node&lt;E&gt; current; // current node; null until initialized
        <i>1129</i>&nbsp; int est; // size estimate; -1 until first needed
        <i>1130</i>&nbsp; int expectedModCount; // initialized when est set
        <i>1131</i>&nbsp; int batch; // batch size for splits
        <i>1132</i>&nbsp;
        <b class="nc"><i>1133</i>&nbsp; LLSpliterator(LinkedList&lt;E&gt; list, int est, int expectedModCount) {</b>
        <b class="nc"><i>1134</i>&nbsp; this.list = list;</b>
        <b class="nc"><i>1135</i>&nbsp; this.est = est;</b>
        <b class="nc"><i>1136</i>&nbsp; this.expectedModCount = expectedModCount;</b>
        <i>1137</i>&nbsp; }
        <i>1138</i>&nbsp;
        <i>1139</i>&nbsp; final int getEst() {
        <i>1140</i>&nbsp; int s; // force initialization
        <i>1141</i>&nbsp; final LinkedList&lt;E&gt; lst;
        <b class="nc"><i>1142</i>&nbsp; if ((s = est) &lt; 0) {</b>
        <b class="nc"><i>1143</i>&nbsp; if ((lst = list) == null) {</b>
        <b class="nc"><i>1144</i>&nbsp; s = est = 0;</b>
        <i>1145</i>&nbsp; } else {
        <b class="nc"><i>1146</i>&nbsp; expectedModCount = lst.modCount;</b>
        <b class="nc"><i>1147</i>&nbsp; current = lst.first;</b>
        <b class="nc"><i>1148</i>&nbsp; s = est = lst.size;</b>
        <i>1149</i>&nbsp; }
        <i>1150</i>&nbsp; }
        <b class="nc"><i>1151</i>&nbsp; return s;</b>
        <i>1152</i>&nbsp; }
        <i>1153</i>&nbsp;
        <i>1154</i>&nbsp; @Override
        <i>1155</i>&nbsp; public long estimateSize() {
        <b class="nc"><i>1156</i>&nbsp; return getEst();</b>
        <i>1157</i>&nbsp; }
        <i>1158</i>&nbsp;
        <i>1159</i>&nbsp; @Override
        <i>1160</i>&nbsp; public Spliterator&lt;E&gt; trySplit() {
        <i>1161</i>&nbsp; Node&lt;E&gt; p;
        <b class="nc"><i>1162</i>&nbsp; int s = getEst();</b>
        <b class="nc"><i>1163</i>&nbsp; if (s &gt; 1 &amp;&amp; (p = current) != null) {</b>
        <b class="nc"><i>1164</i>&nbsp; int n = batch + BATCH_UNIT;</b>
        <b class="nc"><i>1165</i>&nbsp; if (n &gt; s) {</b>
        <b class="nc"><i>1166</i>&nbsp; n = s;</b>
        <i>1167</i>&nbsp; }
        <b class="nc"><i>1168</i>&nbsp; if (n &gt; MAX_BATCH) {</b>
        <b class="nc"><i>1169</i>&nbsp; n = MAX_BATCH;</b>
        <i>1170</i>&nbsp; }
        <b class="nc"><i>1171</i>&nbsp; Object[] a = new Object[n];</b>
        <b class="nc"><i>1172</i>&nbsp; int j = 0;</b>
        <i>1173</i>&nbsp; do {
        <b class="nc"><i>1174</i>&nbsp; a[j++] = p.item;</b>
        <b class="nc"><i>1175</i>&nbsp; } while ((p = p.next) != null &amp;&amp; j &lt; n);</b>
        <b class="nc"><i>1176</i>&nbsp; current = p;</b>
        <b class="nc"><i>1177</i>&nbsp; batch = j;</b>
        <b class="nc"><i>1178</i>&nbsp; est = s - j;</b>
        <b class="nc"><i>1179</i>&nbsp; return Spliterators.spliterator(a, 0, j, Spliterator.ORDERED);</b>
        <i>1180</i>&nbsp; }
        <b class="nc"><i>1181</i>&nbsp; return null;</b>
        <i>1182</i>&nbsp; }
        <i>1183</i>&nbsp;
        <i>1184</i>&nbsp; @Override
        <i>1185</i>&nbsp; public void forEachRemaining(Consumer&lt;? super E&gt; action) {
        <i>1186</i>&nbsp; Node&lt;E&gt; p;
        <i>1187</i>&nbsp; int n;
        <b class="nc"><i>1188</i>&nbsp; if (action == null) {</b>
        <b class="nc"><i>1189</i>&nbsp; throw new NullPointerException();</b>
        <i>1190</i>&nbsp; }
        <b class="nc"><i>1191</i>&nbsp; if ((n = getEst()) &gt; 0 &amp;&amp; (p = current) != null) {</b>
        <b class="nc"><i>1192</i>&nbsp; current = null;</b>
        <b class="nc"><i>1193</i>&nbsp; est = 0;</b>
        <i>1194</i>&nbsp; do {
        <b class="nc"><i>1195</i>&nbsp; E e = p.item;</b>
        <b class="nc"><i>1196</i>&nbsp; p = p.next;</b>
        <b class="nc"><i>1197</i>&nbsp; action.accept(e);</b>
        <b class="nc"><i>1198</i>&nbsp; } while (p != null &amp;&amp; --n &gt; 0);</b>
        <i>1199</i>&nbsp; }
        <b class="nc"><i>1200</i>&nbsp; if (list.modCount != expectedModCount) {</b>
        <b class="nc"><i>1201</i>&nbsp; throw new ConcurrentModificationException();</b>
        <i>1202</i>&nbsp; }
        <i>1203</i>&nbsp; }
        <i>1204</i>&nbsp;
        <i>1205</i>&nbsp; @Override
        <i>1206</i>&nbsp; public boolean tryAdvance(Consumer&lt;? super E&gt; action) {
        <i>1207</i>&nbsp; Node&lt;E&gt; p;
        <b class="nc"><i>1208</i>&nbsp; if (action == null) {</b>
        <b class="nc"><i>1209</i>&nbsp; throw new NullPointerException();</b>
        <i>1210</i>&nbsp; }
        <b class="nc"><i>1211</i>&nbsp; if (getEst() &gt; 0 &amp;&amp; (p = current) != null) {</b>
        <b class="nc"><i>1212</i>&nbsp; --est;</b>
        <b class="nc"><i>1213</i>&nbsp; E e = p.item;</b>
        <b class="nc"><i>1214</i>&nbsp; current = p.next;</b>
        <b class="nc"><i>1215</i>&nbsp; action.accept(e);</b>
        <b class="nc"><i>1216</i>&nbsp; if (list.modCount != expectedModCount) {</b>
        <b class="nc"><i>1217</i>&nbsp; throw new ConcurrentModificationException();</b>
        <i>1218</i>&nbsp; }
        <b class="nc"><i>1219</i>&nbsp; return true;</b>
        <i>1220</i>&nbsp; }
        <b class="nc"><i>1221</i>&nbsp; return false;</b>
        <i>1222</i>&nbsp; }
        <i>1223</i>&nbsp;
        <i>1224</i>&nbsp; @Override
        <i>1225</i>&nbsp; public int characteristics() {
        <b class="nc"><i>1226</i>&nbsp; return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;</b>
        <i>1227</i>&nbsp; }
        <i>1228</i>&nbsp; }
        <i>1229</i>&nbsp;
        <i>1230</i>&nbsp; private class ListItr implements ListIterator&lt;E&gt; {
        <b class="nc"><i>1231</i>&nbsp; private Node&lt;E&gt; lastReturned = null;</b>
        <i>1232</i>&nbsp; private Node&lt;E&gt; next;
        <i>1233</i>&nbsp; private int nextIndex;
        <b class="nc"><i>1234</i>&nbsp; private int expectedModCount = modCount;</b>
        <i>1235</i>&nbsp;
        <b class="nc"><i>1236</i>&nbsp; ListItr(int index) {</b>
        <i>1237</i>&nbsp; // assert isPositionIndex(index);
        <b class="nc"><i>1238</i>&nbsp; next = (index == size) ? null : node(index);</b>
        <b class="nc"><i>1239</i>&nbsp; nextIndex = index;</b>
        <i>1240</i>&nbsp; }
        <i>1241</i>&nbsp;
        <i>1242</i>&nbsp; @Override
        <i>1243</i>&nbsp; public boolean hasNext() {
        <b class="nc"><i>1244</i>&nbsp; return nextIndex &lt; size;</b>
        <i>1245</i>&nbsp; }
        <i>1246</i>&nbsp;
        <i>1247</i>&nbsp; @Override
        <i>1248</i>&nbsp; public E next() {
        <b class="nc"><i>1249</i>&nbsp; checkForComodification();</b>
        <b class="nc"><i>1250</i>&nbsp; if (!hasNext()) {</b>
        <b class="nc"><i>1251</i>&nbsp; throw new NoSuchElementException();</b>
        <i>1252</i>&nbsp; }
        <i>1253</i>&nbsp;
        <b class="nc"><i>1254</i>&nbsp; lastReturned = next;</b>
        <b class="nc"><i>1255</i>&nbsp; next = next.next;</b>
        <b class="nc"><i>1256</i>&nbsp; nextIndex++;</b>
        <b class="nc"><i>1257</i>&nbsp; return lastReturned.item;</b>
        <i>1258</i>&nbsp; }
        <i>1259</i>&nbsp;
        <i>1260</i>&nbsp; @Override
        <i>1261</i>&nbsp; public boolean hasPrevious() {
        <b class="nc"><i>1262</i>&nbsp; return nextIndex &gt; 0;</b>
        <i>1263</i>&nbsp; }
        <i>1264</i>&nbsp;
        <i>1265</i>&nbsp; @Override
        <i>1266</i>&nbsp; public E previous() {
        <b class="nc"><i>1267</i>&nbsp; checkForComodification();</b>
        <b class="nc"><i>1268</i>&nbsp; if (!hasPrevious()) {</b>
        <b class="nc"><i>1269</i>&nbsp; throw new NoSuchElementException();</b>
        <i>1270</i>&nbsp; }
        <i>1271</i>&nbsp;
        <b class="nc"><i>1272</i>&nbsp; lastReturned = next = (next == null) ? last : next.prev;</b>
        <b class="nc"><i>1273</i>&nbsp; nextIndex--;</b>
        <b class="nc"><i>1274</i>&nbsp; return lastReturned.item;</b>
        <i>1275</i>&nbsp; }
        <i>1276</i>&nbsp;
        <i>1277</i>&nbsp; @Override
        <i>1278</i>&nbsp; public int nextIndex() {
        <b class="nc"><i>1279</i>&nbsp; return nextIndex;</b>
        <i>1280</i>&nbsp; }
        <i>1281</i>&nbsp;
        <i>1282</i>&nbsp; @Override
        <i>1283</i>&nbsp; public int previousIndex() {
        <b class="nc"><i>1284</i>&nbsp; return nextIndex - 1;</b>
        <i>1285</i>&nbsp; }
        <i>1286</i>&nbsp;
        <i>1287</i>&nbsp; @Override
        <i>1288</i>&nbsp; public void remove() {
        <b class="nc"><i>1289</i>&nbsp; checkForComodification();</b>
        <b class="nc"><i>1290</i>&nbsp; if (lastReturned == null) {</b>
        <b class="nc"><i>1291</i>&nbsp; throw new IllegalStateException();</b>
        <i>1292</i>&nbsp; }
        <i>1293</i>&nbsp;
        <b class="nc"><i>1294</i>&nbsp; Node&lt;E&gt; lastNext = lastReturned.next;</b>
        <b class="nc"><i>1295</i>&nbsp; unlink(lastReturned);</b>
        <b class="nc"><i>1296</i>&nbsp; if (next == lastReturned) {</b>
        <b class="nc"><i>1297</i>&nbsp; next = lastNext;</b>
        <i>1298</i>&nbsp; } else {
        <b class="nc"><i>1299</i>&nbsp; nextIndex--;</b>
        <i>1300</i>&nbsp; }
        <b class="nc"><i>1301</i>&nbsp; lastReturned = null;</b>
        <b class="nc"><i>1302</i>&nbsp; expectedModCount++;</b>
        <i>1303</i>&nbsp; }
        <i>1304</i>&nbsp;
        <i>1305</i>&nbsp; @Override
        <i>1306</i>&nbsp; public void set(E e) {
        <b class="nc"><i>1307</i>&nbsp; if (lastReturned == null) {</b>
        <b class="nc"><i>1308</i>&nbsp; throw new IllegalStateException();</b>
        <i>1309</i>&nbsp; }
        <b class="nc"><i>1310</i>&nbsp; checkForComodification();</b>
        <b class="nc"><i>1311</i>&nbsp; lastReturned.item = e;</b>
        <i>1312</i>&nbsp; }
        <i>1313</i>&nbsp;
        <i>1314</i>&nbsp; @Override
        <i>1315</i>&nbsp; public void add(E e) {
        <b class="nc"><i>1316</i>&nbsp; checkForComodification();</b>
        <b class="nc"><i>1317</i>&nbsp; lastReturned = null;</b>
        <b class="nc"><i>1318</i>&nbsp; if (next == null) {</b>
        <b class="nc"><i>1319</i>&nbsp; linkLast(e);</b>
        <i>1320</i>&nbsp; } else {
        <b class="nc"><i>1321</i>&nbsp; linkBefore(e, next);</b>
        <i>1322</i>&nbsp; }
        <b class="nc"><i>1323</i>&nbsp; nextIndex++;</b>
        <b class="nc"><i>1324</i>&nbsp; expectedModCount++;</b>
        <i>1325</i>&nbsp; }
        <i>1326</i>&nbsp;
        <i>1327</i>&nbsp; @Override
        <i>1328</i>&nbsp; public void forEachRemaining(Consumer&lt;? super E&gt; action) {
        <b class="nc"><i>1329</i>&nbsp; Objects.requireNonNull(action);</b>
        <b class="nc"><i>1330</i>&nbsp; while (modCount == expectedModCount &amp;&amp; nextIndex &lt; size) {</b>
        <b class="nc"><i>1331</i>&nbsp; action.accept(next.item);</b>
        <b class="nc"><i>1332</i>&nbsp; lastReturned = next;</b>
        <b class="nc"><i>1333</i>&nbsp; next = next.next;</b>
        <b class="nc"><i>1334</i>&nbsp; nextIndex++;</b>
        <i>1335</i>&nbsp; }
        <b class="nc"><i>1336</i>&nbsp; checkForComodification();</b>
        <i>1337</i>&nbsp; }
        <i>1338</i>&nbsp;
        <i>1339</i>&nbsp; final void checkForComodification() {
        <b class="nc"><i>1340</i>&nbsp; if (modCount != expectedModCount) {</b>
        <b class="nc"><i>1341</i>&nbsp; throw new ConcurrentModificationException();</b>
        <i>1342</i>&nbsp; }
        <i>1343</i>&nbsp; }
        <i>1344</i>&nbsp; }
        <i>1345</i>&nbsp;
        <i>1346</i>&nbsp; /**
        <i>1347</i>&nbsp; * Adapter to provide descending iterators via ListItr.previous
        <i>1348</i>&nbsp; */
        <b class="nc"><i>1349</i>&nbsp; private class DescendingIterator implements Iterator&lt;E&gt; {</b>
        <b class="nc"><i>1350</i>&nbsp; private final ListItr itr = new ListItr(size());</b>
        <i>1351</i>&nbsp;
        <i>1352</i>&nbsp; @Override
        <i>1353</i>&nbsp; public boolean hasNext() {
        <b class="nc"><i>1354</i>&nbsp; return itr.hasPrevious();</b>
        <i>1355</i>&nbsp; }
        <i>1356</i>&nbsp;
        <i>1357</i>&nbsp; @Override
        <i>1358</i>&nbsp; public E next() {
        <b class="nc"><i>1359</i>&nbsp; return itr.previous();</b>
        <i>1360</i>&nbsp; }
        <i>1361</i>&nbsp;
        <i>1362</i>&nbsp; @Override
        <i>1363</i>&nbsp; public void remove() {
        <b class="nc"><i>1364</i>&nbsp; itr.remove();</b>
        <i>1365</i>&nbsp; }
        <i>1366</i>&nbsp; }
        <i>1367</i>&nbsp;
        <i>1368</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-11 23:52</div>
</div>
</body>
</html>
